# ca_test.py  3/1/2014  Parker MacCready
"""
Code to test reading the csv files from Environment Canada
"""

import numpy as np
from pandas import Series, DataFrame
import pandas as pd

fn = 'Parker20140212.csv'

df = DataFrame.from_csv(fn,header=11, index_col=1)

df_temp = df[df[' Parameter identification']==5]

df_flow = df[df[' Parameter identification']==47]

# plot results

import matplotlib.pyplot as plt
plt.close()

tt = pd.to_datetime(df_temp.index)
tq = pd.to_datetime(df_flow.index)

ax = plt.subplot(2,1,1)
ax.plot(tq, df_flow[' Value'].values, 'ko--')
ax.set_title(fn)
ax.set_ylabel('Flow m3 s-1')
ax.set_xticks(tt)
ax.set_xticklabels(tt.hour)

ax = plt.subplot(2,1,2)
ax.plot(tt, df_temp[' Value'].values, 'ko--')
ax.set_xlabel('Hour of ' + str(tt[0].year) + '/' + str(tt[0].month) + '/' + str(tt[0].day))
ax.set_ylabel('T degC')
ax.set_xticks(tt)
ax.set_xticklabels(tt.hour)

plt.show()

